<template>
	<up-calendar
		:show="modelValue"
		:mode="'single'"
		:default-date="dayjs().add(2, 'day').format('YYYY-MM-DD')"
		:min-date="dayjs().add(2, 'day').format('YYYY-MM-DD')"
		:max-date="dayjs().add(6, 'M').format('YYYY-MM-DD')"
		@confirm="handleCalendarConfirm"
		@close="handleClose"
	></up-calendar>
</template>

<script setup lang="ts">
import dayjs from "dayjs"

defineProps({
	modelValue: {
		// v-model绑定值
		type: Boolean,
		default: false,
	},
})

const emit = defineEmits(["update:modelValue", "confirm", "cancel"])

// 处理日历确认选择
const handleCalendarConfirm = (date: Array<string>) => {
	emit("confirm", date[0])
	handleClose()
}

// 处理关闭日历
const handleClose = () => {
	emit("update:modelValue", false)
	emit("cancel")
}
</script>
